package com.yang.train.member.config;

import com.yang.train.common.interceptor.LogInterceptor;
import com.yang.train.common.interceptor.MemberInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
 * 拦截器生效配置 MemberInterceptor、
 */
@Configuration
public class SpringMvcConfig implements WebMvcConfigurer {


   @Resource
   LogInterceptor logInterceptor;

   @Resource
   MemberInterceptor memberInterceptor;

   @Override
   public void addInterceptors(InterceptorRegistry registry) {
       // 日志拦截器 添加日志流水号
       registry.addInterceptor(logInterceptor);
        //路径不应包含context-path
       registry.addInterceptor(memberInterceptor)
               .addPathPatterns("/**")
               .excludePathPatterns(
                       "/hello",
                       "/member/send-code",
                       "/member/login"
               );
   }
}
